package com.qhit.dao.impl;

import com.qhit.dao.BaseDao;
import com.qhit.entity.Teacher;

import java.util.List;

/**
 * TODO
 *
 * @author 村头老杨头
 * @version 1.0
 * @date 2021/9/28 16:51
 */
public class TeacherDaoImpl extends BaseDao {
    public List<Teacher> getTeacherList(){
        String sql = "select * from teacher";
        return executeQuery(sql, Teacher.class);
    }
    public Teacher getTeacherById(String tno){
        String sql = "select * from teacher where tno=?";
        List list = executeQuery(sql, Teacher.class, tno);
        if(list!=null && list.size()>0){
            return (Teacher) list.get(0);
        }
        return null;
    }
    public int addTeacher(Teacher teacher){
        String sql = "insert into teacher  values (?,?,?,?,?,?)";
        return executeUpdate(sql,teacher.getTno(),teacher.getTname(),teacher.getTsex(), teacher.getTbirthday(),teacher.getProf(),teacher.getDepart());
    }
    public int deleteTeacher(String tno){
        String sql = "delete from teacher where tno=?";
        return executeUpdate(sql,tno);
    }
    public int updateTeacher(Teacher teacher){
        String sql = "update teacher set tname=?,tsex=?,tbirthday=?,prof=?,depart=? where tno=?";
        return executeUpdate(sql,teacher.getTname(),teacher.getTsex(), teacher.getTbirthday(),teacher.getProf(),teacher.getDepart(),teacher.getTno());
    }
}
